import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:x_common_utils/utils/inkWell_util.dart';
import 'package:xinxuan/common/pay_password/my_pay_password.dart';
import 'package:xinxuan/router/app_routers.dart';
import 'package:xinxuan/utils/color_util.dart';

class UnionPayDialog extends StatelessWidget {

  final String payPrice;
  final ValueChanged<String> onSubmitted;
  UnionPayDialog({
    required this.payPrice,
    required this.onSubmitted
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: Material(
        type: MaterialType.transparency,
        child: Center(
          child: Stack(
            children: [
              Container(
                width: 320.w,
                padding: EdgeInsets.symmetric(vertical: 32.h),
                decoration: BoxDecoration(
                  color: bgWhiteColor,
                  borderRadius: BorderRadius.circular(12.w)
                ),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Text(
                      '请输入支付密码',
                      style: TextStyle(
                        color: textBlackColor,
                        fontSize: 20.sp
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.symmetric(vertical: 20.h),
                      child: Text(
                      '付款$payPrice',
                        style: TextStyle(
                          color: textBlackColor,
                          fontSize: 14.sp
                        ),
                      ),
                    ),
                    Container(
                      alignment: Alignment.center,
                      padding: EdgeInsets.symmetric(horizontal: 15.w),
                      child: Container(
                        height: 44.h,
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(5.w),
                          border: Border.all(
                            color: lineColor,
                            width: 1.w
                          )
                        ),
                        child: MyPayPassword(
                          count: 6,
                          itemWidget: 48.w,
                          borderWidth: 1.w,
                          showCursor: false,
                          autoFocus: true,
                          cursorColor: textBlackColor,
                          focusBorderColor: lineColor,
                          textStyle: TextStyle(
                            fontSize: 12.sp,
                            color: textBlackColor
                          ),
                          borderRadius: 0,
                          onSubmitted: (value) => onSubmitted(value)
                        ),
                      )
                    ),
                    Container(
                      alignment: Alignment.centerRight,
                      padding: EdgeInsets.only(top: 20.h, right: 16.w),
                      child: InkWellUtil.shakeProofInkWell(Text(
                        '忘记密码？',
                        style: TextStyle(
                          color: textSubtitleColor,
                          fontSize: 14.sp
                        )
                      ), () {
                        Get.back();
                        Get.toNamed('${AppRouters.COMMON_PAGE}${AppRouters.MY_INFO_PAGE}${AppRouters.UPDATE_PAY_PASSWORD_PAGE}');
                      }),
                    )
                  ],
                ),
              ),
              Positioned(
                top: 16.w,
                right: 16.w,
                child: InkWellUtil.shakeProofInkWell(Image.asset(
                  'assets/icons/icon_close.png',
                  width: 20.w,
                  height: 20.w,
                ), () {
                  Get.back();
                })
              )
            ],
          ),
        ),
      ),
    );
  }
}